package summer.codegenerator.common.util;

import java.util.Map;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

public class ParamUtil {

	public static String GetStringParam(Map<String, Object> param, String key) {
		Object obj = param.get(key);
		if (obj == null) {
			return "";
		}
		return String.valueOf(obj);
	}

	public static Long GetLongParam(Map<String, Object> param, String key) {
		Object obj = param.get(key);
		if (obj == null) {
			return null;
		}
		return Long.valueOf(String.valueOf(obj));
	}

	public static Integer GetIntParam(Map<String, Object> param, String key) {
		Object obj = param.get(key);
		if (obj == null) {
			return null;
		}
		return Integer.valueOf(String.valueOf(obj));
	}

	public static String GetStringParam(JSONObject param, String key) {
		Object obj = param.get(key);
		if (obj == null) {
			return "";
		}
		return String.valueOf(obj);
	}

	public static JSONArray GetJSONArrayParam(JSONObject param, String key) {
		Object obj = param.get(key);
		if (obj == null) {
			return null;
		}
		return param.getJSONArray(key);
	}
}
